//
//  RanPhotoSelectionModel.m
//  testAVFoundation
//
//  Created by Ran on 15/11/5.
//  Copyright (c) 2015年 gintong. All rights reserved.
//

#import "RanPhotoSelectionModel.h"
#import <AssetsLibrary/AssetsLibrary.h>

@implementation RanPhotoSelectionModel

- (UIImage *)fullScreenImage
{
    if (!_fullScreenImage) {
        ALAssetRepresentation *representation = [self.asset defaultRepresentation];
        self.fullScreenImage = [UIImage imageWithCGImage:representation.fullScreenImage];
    }
    return _fullScreenImage;
}

- (UIImage *)originalImage
{

//    if (!_originalImage) {
        ALAssetRepresentation *representation = [self.asset defaultRepresentation];
        return [UIImage imageWithCGImage:representation.fullResolutionImage];
//        self.originalImage =
//    }
//    return _originalImage;
}

- (NSString *)timeText
{
    if (!_timeText) {
        if (self.duration > 0) {
            int duration = nearbyintf(self.duration);
            int hour = duration / 3600;
            int minute = duration % 3600 / 60;
            int second = duration % 60;
            if (hour > 0) {
                _timeText = [NSString stringWithFormat:@"%d:%02d:%02d", hour, minute, second];
            }else{
                _timeText = [NSString stringWithFormat:@"%d:%02d", minute, second];
            }
        }else{
            _timeText = @"";
        }
    }
    return _timeText;
}

@end
